FUNCTION OpenFile
RETURNS LOGICAL
  ( /* parameter-definitions */ 
    INPUT ipcFileName AS CHAR
  ) :
/*------------------------------------------------------------------------------
  Purpose:  Opens a file with it's registered application
    Notes:  Can be used to "Open" anything, from a word document, 
            an excel spreadsheet, a web site. You can even use it to
            send e-mail passing e.g.:
            mailto:wim@inrete.it
------------------------------------------------------------------------------*/
def var tvi_Instance as int no-undo.

   RUN ShellExecuteA (0,
                      "open",
                      ipcFileName,
                      "",
                      "",
                      1,
                      output tvi_Instance).

   IF tvi_Instance LT 32 THEN DO:
      PUBLISH "messaggio" (PROGRAM-NAME(1), 0, SUBSTITUTE("ShellExecuteA: &1", tvi_Instance)).
   END.

   RETURN (tvi_Instance GT 32).

END FUNCTION.

/* Variabili locali */
DEFINE VARIABLE dtDataDa     AS DATE       NO-UNDO.
DEFINE VARIABLE dtDataA      AS DATE       NO-UNDO.
DEFINE VARIABLE iProject     AS INTEGER    NO-UNDO.
DEFINE VARIABLE cMeds        AS CHARACTER  NO-UNDO.
DEFINE VARIABLE iIntervento  AS INTEGER    NO-UNDO.
DEFINE VARIABLE hTTRiepilogo AS HANDLE     NO-UNDO.
DEFINE VARIABLE hTTValore    AS HANDLE     NO-UNDO.
DEFINE VARIABLE cFileName    AS CHARACTER  NO-UNDO.
DEFINE VARIABLE lOpen        AS LOGICAL    NO-UNDO.

ASSIGN
   dtDataDa    = DATE(6,17,2006)
   dtDataA     = DATE(10,31,2006)
   iProject    = 20 /* Comune Milano Manutenzione 2006 */
   cMeds       = "*"
   iIntervento = 59 /* Ultima bollettina inserita */
   cFileName   = "C:\temp\Bollettine Secondo semestre 2006 A.html"
.

RUN tm\p\creabolrich.p
   (INPUT dtDataDa,
    INPUT dtDataA,
    INPUT iProject,
    INPUT cMeds,
    INPUT iIntervento,
    OUTPUT TABLE-HANDLE hTTRiepilogo,
    OUTPUT TABLE-HANDLE hTTValore).

ASSIGN
   hTTRiepilogo:PRIVATE-DATA = SUBSTITUTE("Titolo=&1",
                                 "Bollettine Secondo semestre 2006 A")
.

RUN sy/p/tt2html.p
   (INPUT hTTRiepilogo,
    INPUT "NumeroIntervento,RifInterno,Settore,Ufficio,Richiedente,Procedura,DataRichiesta,DataPresaInCarico,Specialista,TipoIntervento,DataIntervento,DataRegistrazione,DescrizioneIntervento,lEsecuzioneTest,lSupportoMessaInEsercizio,lIstruzioniOperative,lDocumentazione,lCollaudo,DataChiusura,Figure",
    INPUT cFileName).

lOpen = TRUE.
MESSAGE "Aprire Bollettine ?"
   VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO-CANCEL UPDATE lOpen.
IF lOpen = ? THEN
   RETURN.

IF lOpen = TRUE THEN
   OpenFile(cFileName).

RUN sy/win/wbrowsett.w
   (INPUT hTTValore).

PROCEDURE ShellExecuteA EXTERNAL "shell32" :
   define input parameter hwnd as long.
   define input parameter lpOperation as char.
   define input parameter lpFile as char.
   define input parameter lpParameters as char.
   define input parameter lpDirectory as char.
   define input parameter nShowCmd as long.
   define return parameter hInstance as long.
END PROCEDURE. /* ShellExecuteA */
